# -*- coding: utf-8 -*-
# @File     : serializers.py
# @Author   : bingjia
# @Time     : 2020/7/27 16:41
# @Desc     : user序列化

from ..base.api import serializers

from . import models


class LeaseServiceSerializer(serializers.ModelSerializer):
    """
    服务序列化
    """
    service_type = serializers.SerializerMethodField()

    class Meta:
        model = models.LeaseService
        fields = ['id', 'service_name', 'service_type', 'service_price', 'service_description']

    def get_service_type(self, obj):
        return obj.get_service_type_display


class LeaseModelSerializer(serializers.ModelSerializer):
    """
    模型序列化
    """
    model = serializers.SerializerMethodField()

    class Meta:
        model = models.LeaseModel
        fields = ['id', 'username', 'service_price', 'service_description']

    def get_model(self, obj):
        return obj.get_model_display








